package com.example.demo.command;


import com.example.demo.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.shell.standard.ShellCommandGroup;
import org.springframework.shell.standard.ShellMethod;
import org.springframework.shell.standard.ShellComponent;

import javax.validation.constraints.Size;

@ShellComponent
@ShellCommandGroup("operate ctl")
public class MyCommands{

    @Autowired
    private TestService service;

    @ShellMethod(value = "add two num.", key = "sum")
    public int add(int a, int b) {
        service.move();
        return a + b;
    }

    @ShellMethod(value = "mult two num." , key = "sum11")
    public int mult(int a, int b) {
        service.move();
        return a * b;
    }

    @ShellMethod(value = "change password.", key= "cpwd")
    public String changePassword(@Size(min = 8, max = 40) String password) {
        return "Password successfully set to " + password;
    }

}
